﻿using Hr.DAL;
using Hr.IBLL;
using Hr.IDAL;
using Hr.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hr.BLL
{
   public partial class NoticeService :BaseService<Notice_List>,INoticeService
    {
        private INoticeDAL INotice = Hr.DALContainer.Container.Resolve<INoticeDAL>();

        protected NoticeDAL ND = new NoticeDAL();

        /// <summary>
        /// 获取通知管理信息
        /// </summary>
        /// <returns></returns>
        public Dictionary<string,object> GetNoticeList(int page,int limit,string Notices)
        {
            Dictionary<string, object> dt = new Dictionary<string, object>()
            {
                {"NoticeList",  ND.GetNoticeList(Notices).Skip(limit*(page-1)).Take(limit)},
                {"NoticeCount",ND.GetNoticeList(Notices).Count() }
            };
            return dt;
        }
        
        /// <summary>
        /// 获取通知列表信息
        /// </summary>
        /// <returns></returns>
        public Dictionary<string,object> GetViewList(int page, int limit,string Title)
        {
            Dictionary<string, object> dt = new Dictionary<string, object>()
           {
               {"NoticeList", ND.GetViewLIist(Title).Skip(limit*(page-1)).Take(limit)},
                {"Noticecount",ND.GetViewLIist(Title).Count()}
           };
            return dt;
        }

        /// <summary>
        /// 获取类型
        /// </summary>
        /// <returns></returns>
        public Dictionary<string, object> GetTypeList()
        {
            Dictionary<string, object> dt = new Dictionary<string, object>()
           {
               {"Type",ND.GetMyModels<Sys_TypeID>(n=>n.TableName.Equals("Notice_List"))},
               {"Status",ND.GetMyModels<Sys_StatusID>(n=>n.TableName.Equals("Notice_List"))}
           };
            return dt;
        }

        /// <summary>
        /// 根据Id获取通知管理
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Notice_List GetNotionInfo(int id)
        {
            return ND.GetNoticeInfo(id);
        }

        /// <summary>
        /// 根据id获取数据
        /// </summary>
        /// <returns></returns>
        public List<Notice_List> GetNoticeAll()
        {
            return ND.GetNoticeAll();
        }

        /// <summary>
        /// 查看公告
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public object GetNoticeDesc(int id)
        {
            return ND.GetNoticDesc(id);
        }

        /// <summary>
        /// 添加，修改公告管理
        /// </summary>
        /// <param name="n"></param>
        /// <param name="Type"></param>
        /// <returns></returns>
        public bool UpdateNotice(Notice_List n,string Type,int pk_User)
        {
            ND.UpdateNotice(n, Type,pk_User);
            return ND.SaveChanges();
        }


        public override void SetDal()
        {
            Dal = INotice;
        }
    }
}
